﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace FAST
{
    /// <summary>
    /// Stores the metadata of a folder.
    /// </summary>
    [Serializable()]
    public class FolderHandler : FilesHandler
    {
        private string fullFolderPath;
        private string subFolderPath;//exclude root path
        private DirectoryInfo di;
        private bool dirtyBit;
        private int status;

        /// <summary>
        /// Constructor to initiate the FolderHandler.
        /// </summary>
        public FolderHandler()
        {
            fullFolderPath = "";
            subFolderPath = "";
            this.di = null;
            dirtyBit = false;
            status = 7; //NOT_EXIST
            setTypeFile(false);
        }

        /// <summary>
        /// Contructor that takes in two parameters, a fullFolderPath and a subFolderPath.
        /// </summary>
        /// <param name="fullFolderPath">Path of the root folder directory<</param>
        /// <param name="subFolderPath">Path of the folder, exclude the root path</param>
        public FolderHandler(string fullFolderPath, string subFolderPath)
        {
            this.fullFolderPath = fullFolderPath;
            this.subFolderPath = subFolderPath;
            this.di = new DirectoryInfo(fullFolderPath);
            this.dirtyBit = false;
            this.status = 7; //NOT_EXIST
            setTypeFile(false);
        }

        /// <summary>
        /// Contructor that takes in five parameters, a fullFolderPath, subFolderPath, fi, dirtyBit, status.
        /// </summary>
        /// <param name="fullFolderPath">Path of the root folder directory</param>
        /// <param name="subFolderPath">Path of the folder, exclude the root path</param>
        /// <param name="fi">File info of folder</param>
        /// <param name="dirtyBit">Dirty bit of the folder</param>
        /// <param name="status">Status of the folder</param>
        public FolderHandler(string fullFolderPath, string subFolderPath, DirectoryInfo fi, bool dirtyBit, int status)
        {
            this.fullFolderPath = fullFolderPath;
            this.subFolderPath = subFolderPath;
            this.di = fi;
            this.dirtyBit = dirtyBit;
            this.status = status;
            setTypeFile(false);
        }

        //Overload constructor for Comparing object
        public FolderHandler(string fullFolderPath)
        {
            this.fullFolderPath = fullFolderPath;
            setTypeFile(false);
        }

        public int getFolderStatus()
        {
            return this.status;
        }

        public string getSubFolderPath()
        {
            return this.subFolderPath;
        }

        public string getFullFolderPath()
        {
            return this.fullFolderPath;
        }

        public void setSubFolderPath(string subFolderPath)
        {

            this.subFolderPath = subFolderPath;
        }

        public DirectoryInfo getDi()
        {
            return this.di;
        }

        public void setDi(DirectoryInfo di)
        {
            this.di = di;
        }


        public bool isDirty()
        {
            return this.dirtyBit;
        }

        public void setDirtyBit(bool dirtyBit)
        {
            this.dirtyBit = dirtyBit;
        }

        public void setFolderStatus(int status)
        {
            this.status = status;
        }

    }
}
